<html>
<head>
<title></title>
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width,initial-scale=1,user-scalable=no">
<link href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"
	rel="stylesheet" type="text/css">
<link href="../css/yuea.css" rel="stylesheet" type="text/css">
<script src="../js/common3.js"></script>
<script src="../../../common/jquery-3.3.1.min.js"></script>
<script>
var leftSeconds=120;
var arrivalTimeTimer;
var timmerFlag=0;
var code;
var state;
var hasClickGetCode=0;
$(document).ready(function(){
	init();
	var Request=new UrlSearch();
	code=Request.code;
	state=Request.state;
	$("#readedDiv").bind("click",function(){
		if($("#readed").attr("checked")==null){
			$("#readed").attr("checked","checked");
			$("#agree").removeClass("weui-btn_disabled");
		}else{
			$("#readed").removeAttr("checked");
			$("#agree").addClass("weui-btn_disabled");
		}
	});
	}
);

function next(){
	if("checked"==$("#readed").attr("checked")){
		$("#addTel").css("display","block");
		$("#firstUse").css("display","none");
	}
}
function ok(){
	var telNum=$("#myTel").val();
	var verCode=$("#code").val();
	if(telNum==null||telNum.length!=11){
		$("#myTel").val("");
		$("#myTel").focus();
		return;
	}else if(verCode==null||verCode.length!=4){
		$("#code").val("");
		$("#code").focus();
		return;
	}else{
		$("#ok").removeClass("weui-btn_disabled");
	}
	var url = "/yuea/customer/insertOrModify?userPageAuthCode="
		+ code+"&verCode="+verCode;
	var data={};
	data.telNum=$("#myTel").val();
	$.ajax({
        url: url,
        type: "PATCH",
        contentType: "application/json",
		data:JSON.stringify(data),
        success: function(response) {
        	if(response.state="BUSI_STATE_OK"){
        		switchPage();
        	}
        }
	});
}
function switchPage(){
	if(state==1){
		window.location.href="/yuea/client/hair/html/lineUp/beginLineUp.html?code="+ code;
	}else if(state==2){
		window.location.href="/yuea/client/hair/html/appointment/makeAnAppointment.html?code="+ code;
	}else if(state==3){
		window.location.href="/yuea/client/hair/html/personal/personalInfo.html?code="+ code;
	}
}
function preOk(){
	var telNum=$("#myTel").val();
	var code=$("#code").val();
	if(telNum!=null&&telNum.length==11&&code!=null&&code.length==4){
		$("#ok").removeClass("weui-btn_disabled");
	}else{
		$("#ok").addClass("weui-btn_disabled");
	}
}

function getCode(){
	var telNum=$("#myTel").val();
	if(telNum==null||telNum.length!=11){
		$("#myTel").val("");
		$("#myTel").focus();
	}
	preOk();
	var url = "/yuea/currentLineUp/sendVerificationCode?userPageAuthCode="
		+ code+"&telNum="+$("#myTel").val();
	$.ajax({
        url: url,
        type: "get",
        success: function(response) {
        	if(response.state="BUSI_STATE_OK"){
        		if(timmerFlag==0){
        			arrivalTimeTimer=setInterval('setLeftSeconds()',1000); 
        		}
        		hasClickGetCode=1;
        	}
        }
	});
}


	function setLeftSeconds() {
		timmerFlag=1;
		leftSeconds = leftSeconds - 1;
		if(leftSeconds==0){
			timmerFlag=0;
			clearTimeout(arrivalTimeTimer);
			$("#getCode").text("获取验证码");
			leftSeconds=120;
		}else{
			$("#getCode").text(leftSeconds + "秒后重新获取");
		}
	}

	function init() {
		var Request = new UrlSearch();
		var code = Request.code;
		var url = "/yuea/customer/getCustomerInfo?userPageAuthCode="+ code;
		$.ajax({
	        url: url,
	        type: "get",
	        success: function(response) {
	        	if(response.data==null||response.data.telNum==null){
	        		document.title="首次使用";
	        		$("#main").css("display","block");
	        	}else{
	        		switchPage();
	        	}
	        }
		});
	}
</script>
</head>
<body id="main" style="display:none">
	
	<div id="top" class="weui-panel__bd">
		<div class="weui-media-box weui-media-box_appmsg">
			<div class="weui-media-box__hd">
				<img class="weui-media-box__thumb"
					src=""
					alt="">
			</div>
			<div class="weui-cell__bd">
				<p>尊敬的顾客您好，欢迎光临本店，祝您生活愉快！首次使用，请您认真阅读以下须知。</p>
				<!-- <p>尊敬的顾客您好，欢迎光临本店，祝您生活愉快！</p> -->
				<!-- <p>尊敬的顾客，您已成功排队，若不能及时到店，请及时推迟或取消排队，期待您的光临！</p> -->
			</div>
		</div>
	</div>
	<div id="firstUse">
		<div>
			<article class="weui-article" style="color: #666;">
			    <section>
		            <p style="text-indent:25px">
		                                        该公众号是为避免您到店后因顾客较多需长时间等待而开通的。通过该功能您可以<span style="color: #1aad19;">查询店铺的实时运营状态</span>，在家即可<span style="color: #1aad19;">提前排队或预约</span>，从而节省您的时间。
		            </p>
		            <p style="text-indent:25px">
		               	在您排队或预约成功后，<span style="color: #1aad19;">若不能按时到店，请提前推迟或取消</span>，以便对其他顾客尽早接受服务。
		            </p>
		            <p style="text-indent:25px">
		               	为了您的使用体验，提前排队不需要任何预付费用，<span style="color: #1aad19;">若您有不良排队记录，在后续的使用过程中可能需要提前预付款</span>。
		            </p>
		            <p style="text-indent:25px">
		               	因顾客的差异化，可能会导致您的服务时间有少许偏差，敬请体谅。
		            </p>
			    </section>
			</article>
		</div>
		
		<div id="readedDiv">
			<div class="weui-cells_checkbox">
			    <label class="weui-cell weui-check__label" for="s11">
			        <div class="weui-cell__hd">
			            <input type="checkbox" class="weui-check" name="checkbox1" id="readed">
			            <i class="weui-icon-checked"></i>
			        </div>
			        <div class="weui-cell__bd">
			            <p>我已阅读</p>
			        </div>
			    </label>
			</div>
		</div>
		
		<div class="button-sp-area" style="padding: 10px 15px">
			<a id="agree" href="javascript:next();" class="weui-btn weui-btn_primary weui-btn_disabled">下一步</a>
		</div>
	</div>
	
	
	<div id="addTel" style="display:none">
		<div>
			<article class="weui-article" style="color: #666;padding: 0px 15px">
			    <section>
		            <p style="text-indent:25px">
		                                        该手机号用于服务提醒及身份验证，我们会对您的手机号绝对保密，请您放心填写。
		            </p>
			    </section>
			</article>
		</div>
		
		<div class="weui-cells weui-cells_form">
			<div class="weui-cell weui-cell_vcode">
				<div class="weui-cell__hd">
					<label class="weui-label" style="font-size: 15px">手机号</label>
				</div>
				<div class="weui-cell__bd">
					<input id="myTel" class="weui-input" oninput="preOk()" style="font-size: 15px" type="tel" placeholder="请输入手机号">
				</div>
				<div class="weui-cell__ft">
					<a id="getCode" href="javascript:getCode();" class="weui-vcode-btn" style="font-size: 15px">获取验证码</a>
				</div>
			</div>
			<div class="weui-cell">
				<div class="weui-cell__hd">
					<label class="weui-label" style="font-size: 15px">验证码</label>
				</div>
				<div class="weui-cell__bd">
					<input id="code" class="weui-input" oninput="preOk()" style="font-size: 15px" type="number" pattern="[0-9]*"
						placeholder="请输入4位短信验证码" />
				</div>
			</div>
		</div>
		
		<div class="button-sp-area" style="padding: 20px 15px">
			<a id="ok" href="javascript:ok();" class="weui-btn weui-btn_primary weui-btn_disabled">完成</a>
		</div>
	</div>
	
</body>
</html>